Skip to content

Conversation

@DTCurrie
Copy link
Member

@DTCurrie DTCurrie commented Nov 8, 2025

The dialWebRTC function created multiple Transport instances and signaling service clients during connection setup; however, the client retained only the final WebRTC data channel transport, which caused a few issues.

HTTP/2 connection pool buildup

createGrpcWebTransport from @connectrpc/connect-web creates HTTP/2 connections. The Transport uses fetch, and the browser manages persistent connections in its connection pool. By reusing a single Transport instance, we enable the browser to reuse the same underlying HTTP/2 connection for multiple requests to the same origin, rather than potentially creating multiple connection contexts through separate 'Transport' objects.

Memory leaks from abandoned transport states

Transport instances hold internal state (connection pools, request queues, event handlers, authentication headers).
The transport from getOptionalWebRTCConfig was never explicitly closed. The Transport object goes out of scope, but its internal state may persist until the garbage collector runs. With frequent reconnections, this accumulates.

Port exhaustion on frequent reconnects

We created multiple Transport objects for each connection attempt, which could open numerous TCP connections, each consuming a temporary local port. During rapid reconnections, these ports might not be released fast enough, risking port exhaustion. By creating and reusing a single Transport instance, the browser can efficiently manage a single underlying connection and its port, eliminating the risk of exhaustion.

Multiple connections to the signaling service

We were creating two separate client connections to the signaling server: one for optionalWebRTCConfig and one for signaling exchange. These changes create a singleTransport which means one connection handles both operations, reducing server load and connection overhead.

@DTCurrie DTCurrie self-assigned this Nov 8, 2025
…se-transport-and-signaling-client-for-dialing-webrtc
This reverts commit 8c20e5b.
…into reuse-transport-and-signaling-client-for-dialing-webrtc"

This reverts commit 2ae499d, reversing
changes made to f1abc83.
@DTCurrie DTCurrie marked this pull request as ready for review November 10, 2025 20:05
@DTCurrie DTCurrie requested a review from a team as a code owner November 10, 2025 20:05
@DTCurrie DTCurrie requested review from njooma and stuqdog and removed request for a team November 10, 2025 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants